package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.dubbo.mappers.SoulTestQuestionMapper;
import com.tanhua.model.domain.SoulTestQuestion;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @Description：test
 * @Create by： 张会豪
 * @Date：2021/11/8 9:12
 */
@DubboService
public class SoulTestQuestionApiImpl implements SoulTestQuestionApi {

    @Autowired
    private SoulTestQuestionMapper soulTestQuestionMapper;

    //根据questionnaireId查询数据，对应初级、中级、高级
    public List<SoulTestQuestion> findByTypeId(Long questionnaireId) {
        //根据questionnaireId查询数据
        LambdaQueryWrapper<SoulTestQuestion> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SoulTestQuestion::getQuestionnaireId, questionnaireId);
        return soulTestQuestionMapper.selectList(queryWrapper);
    }

    //根据最后一次提交的id查询等级
    public Long findById(Long id) {
        if (id == null) {
            return null;
        }
        LambdaQueryWrapper<SoulTestQuestion> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SoulTestQuestion::getId, id);
        SoulTestQuestion soulTestQuestion = soulTestQuestionMapper.selectOne(queryWrapper);
        return soulTestQuestion.getQuestionnaireId();
    }

}
